{% extends 'base.html' %}
{% block title %}
    {{ block.super }}-首页
{% endblock %}

{% block main %}
    <h1>博客列表</h1>
    <div class="row row-cols-2 row-gap-4">
        {% for blog in blogs %}
            <div class="col">
                <div class="card">
                    <div class="card-header">
                        <a href="{% url 'blog:detail' blog_id=blog.id %}">{{ blog.title }}</a>
                    </div>
                    <div class="card-body" style="min-height: 100px">
                        <p class="card-text">{{ blog.content|striptags|truncatechars:200 }}</p>
                    </div>
                    <div class="card-footer text-body-secondary d-flex justify-content-between">
                        <div>
                            <img class="rounded-circle" width="30px" height="30px"
                                 src="{% static 'image/avatar.webp' %}"
                                 alt="avatar">
                            <span>{{ blog.author.username }}</span>
                        </div>
                        <div>
                            <span>{{ blog.pub_time|date:"Y年m月d日 H时i分s秒" }}</span>
                        </div>
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
{% endblock %}